<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#-- 包含其他文件的内容 -->
    <#include "../common/header.ftl"/>
    <script>
        $(function () {
            $(".inputBtn").click(function () {
                var content=$(this).data('content');
                console.log(content);
                $(".modal-body").html(content);
                $("#lookModal").modal('show');
            })

            $(".commitBtn").click(function () {
                var json = $(this).data('json');
                console.log(json);
                if(json) {
                    $("input[name='article.id']").val(json.id);
                    $("input[name='article.content']").val(json.content);
                }
                $("#editForm").ajaxSubmit(function (data) {
                    handleResult(data);
                })
                location.href="http://localhost:7777/advertisement/list.do";

            })

        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <!--往数据模型中填充一个属性-->
            <#assign menu="advertisement"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">广告管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategy/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword"
                           value="${(qo.keyword)!}" placeholder="请输入标题">
                </div>
                <button id="btn_query" class="btn btn-default" >
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <a role="button" class="btn btn-success inputBtn" >
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>广告标题</th>
                    <th>操作</th>
                </tr>

                <#list pageInfo.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.title!}</td>
                    <td>
                        <a class="btn btn-info btn-xs inputBtn" data-content='${entity.content!}'>
                            <span class="glyphicon glyphicon-pencil" ></span> 显示内容
                        </a>
                        <a class="btn btn-info btn-xs commitBtn" data-json='${entity.json!}'>
                            <span class="glyphicon glyphicon-pencil" ></span> 推送
                        </a>
                    </td>
                </tr>
            </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<#-- 查看内容模态框 -->
<div class="modal fade" id="lookModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">通知内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<form class="form-horizontal" action="/advertisement/addMycomment.do" method="post" id="editForm">

    <input type="hidden" name="article.id">
    <input type="hidden" name="article.content">

</form>
</body>
</html>